{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport get from \"rc-util/es/utils/get\";\nimport set from \"rc-util/es/utils/set\";\nimport { toArray } from './typeUtil';\nimport cloneDeep from '../utils/cloneDeep';\n/**\n * Convert name to internal supported format.\n * This function should keep since we still thinking if need support like `a.b.c` format.\n * 'a' => ['a']\n * 123 => [123]\n * ['a', 123] => ['a', 123]\n */\nexport function getNamePath(path) {\n  return toArray(path);\n}\nexport function getValue(store, namePath) {\n  var value = get(store, namePath);\n  return value;\n}\nexport function setValue(store, namePath, value) {\n  var removeIfUndefined = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n  var newStore = set(store, namePath, value, removeIfUndefined);\n  return newStore;\n}\nexport function cloneByNamePathList(store, namePathList) {\n  var newStore = {};\n  namePathList.forEach(function (namePath) {\n    var value = getValue(store, namePath);\n    newStore = setValue(newStore, namePath, value);\n  });\n  return newStore;\n}\nexport function containsNamePath(namePathList, namePath) {\n  return namePathList && namePathList.some(function (path) {\n    return matchNamePath(path, namePath);\n  });\n}\nfunction isObject(obj) {\n  return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n/**\n * Copy values into store and return a new values object\n * ({ a: 1, b: { c: 2 } }, { a: 4, b: { d: 5 } }) => { a: 4, b: { c: 2, d: 5 } }\n */\nfunction internalSetValues(store, values) {\n  var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread({}, store);\n  if (!values) {\n    return newStore;\n  }\n  Object.keys(values).forEach(function (key) {\n    var prevValue = newStore[key];\n    var value = values[key];\n    // If both are object (but target is not array), we use recursion to set deep value\n    var recursive = isObject(prevValue) && isObject(value);\n    newStore[key] = recursive ? internalSetValues(prevValue, value || {}) : cloneDeep(value); // Clone deep for arrays\n  });\n\n  return newStore;\n}\nexport function setValues(store) {\n  for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n    restValues[_key - 1] = arguments[_key];\n  }\n  return restValues.reduce(function (current, newStore) {\n    return internalSetValues(current, newStore);\n  }, store);\n}\nexport function matchNamePath(namePath, changedNamePath) {\n  if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {\n    return false;\n  }\n  return namePath.every(function (nameUnit, i) {\n    return changedNamePath[i] === nameUnit;\n  });\n}\nexport function isSimilar(source, target) {\n  if (source === target) {\n    return true;\n  }\n  if (!source && target || source && !target) {\n    return false;\n  }\n  if (!source || !target || _typeof(source) !== 'object' || _typeof(target) !== 'object') {\n    return false;\n  }\n  var sourceKeys = Object.keys(source);\n  var targetKeys = Object.keys(target);\n  var keys = new Set([].concat(sourceKeys, targetKeys));\n  return _toConsumableArray(keys).every(function (key) {\n    var sourceValue = source[key];\n    var targetValue = target[key];\n    if (typeof sourceValue === 'function' && typeof targetValue === 'function') {\n      return true;\n    }\n    return sourceValue === targetValue;\n  });\n}\nexport function defaultGetValueFromEvent(valuePropName) {\n  var event = arguments.length <= 1 ? undefined : arguments[1];\n  if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {\n    return event.target[valuePropName];\n  }\n  return event;\n}\n/**\n * Moves an array item from one position in an array to another.\n *\n * Note: This is a pure function so a new array will be returned, instead\n * of altering the array argument.\n *\n * @param array         Array in which to move an item.         (required)\n * @param moveIndex     The index of the item to move.          (required)\n * @param toIndex       The index to move item at moveIndex to. (required)\n */\nexport function move(array, moveIndex, toIndex) {\n  var length = array.length;\n  if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {\n    return array;\n  }\n  var item = array[moveIndex];\n  var diff = moveIndex - toIndex;\n  if (diff > 0) {\n    // move left\n    return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));\n  }\n  if (diff < 0) {\n    // move right\n    return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));\n  }\n  return array;\n}","map":{"version":3,"names":["_objectSpread","_toConsumableArray","_typeof","get","set","toArray","cloneDeep","getNamePath","path","getValue","store","namePath","value","setValue","removeIfUndefined","arguments","length","undefined","newStore","cloneByNamePathList","namePathList","forEach","containsNamePath","some","matchNamePath","isObject","obj","Object","getPrototypeOf","prototype","internalSetValues","values","Array","isArray","keys","key","prevValue","recursive","setValues","_len","restValues","_key","reduce","current","changedNamePath","every","nameUnit","i","isSimilar","source","target","sourceKeys","targetKeys","Set","concat","sourceValue","targetValue","defaultGetValueFromEvent","valuePropName","event","move","array","moveIndex","toIndex","item","diff","slice"],"sources":["/data/messenger.client/node_modules/rc-field-form/es/utils/valueUtil.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport get from \"rc-util/es/utils/get\";\nimport set from \"rc-util/es/utils/set\";\nimport { toArray } from './typeUtil';\nimport cloneDeep from '../utils/cloneDeep';\n/**\n * Convert name to internal supported format.\n * This function should keep since we still thinking if need support like `a.b.c` format.\n * 'a' => ['a']\n * 123 => [123]\n * ['a', 123] => ['a', 123]\n */\nexport function getNamePath(path) {\n  return toArray(path);\n}\nexport function getValue(store, namePath) {\n  var value = get(store, namePath);\n  return value;\n}\nexport function setValue(store, namePath, value) {\n  var removeIfUndefined = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n  var newStore = set(store, namePath, value, removeIfUndefined);\n  return newStore;\n}\nexport function cloneByNamePathList(store, namePathList) {\n  var newStore = {};\n  namePathList.forEach(function (namePath) {\n    var value = getValue(store, namePath);\n    newStore = setValue(newStore, namePath, value);\n  });\n  return newStore;\n}\nexport function containsNamePath(namePathList, namePath) {\n  return namePathList && namePathList.some(function (path) {\n    return matchNamePath(path, namePath);\n  });\n}\nfunction isObject(obj) {\n  return _typeof(obj) === 'object' && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n/**\n * Copy values into store and return a new values object\n * ({ a: 1, b: { c: 2 } }, { a: 4, b: { d: 5 } }) => { a: 4, b: { c: 2, d: 5 } }\n */\nfunction internalSetValues(store, values) {\n  var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread({}, store);\n  if (!values) {\n    return newStore;\n  }\n  Object.keys(values).forEach(function (key) {\n    var prevValue = newStore[key];\n    var value = values[key];\n    // If both are object (but target is not array), we use recursion to set deep value\n    var recursive = isObject(prevValue) && isObject(value);\n    newStore[key] = recursive ? internalSetValues(prevValue, value || {}) : cloneDeep(value); // Clone deep for arrays\n  });\n\n  return newStore;\n}\nexport function setValues(store) {\n  for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n    restValues[_key - 1] = arguments[_key];\n  }\n  return restValues.reduce(function (current, newStore) {\n    return internalSetValues(current, newStore);\n  }, store);\n}\nexport function matchNamePath(namePath, changedNamePath) {\n  if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {\n    return false;\n  }\n  return namePath.every(function (nameUnit, i) {\n    return changedNamePath[i] === nameUnit;\n  });\n}\nexport function isSimilar(source, target) {\n  if (source === target) {\n    return true;\n  }\n  if (!source && target || source && !target) {\n    return false;\n  }\n  if (!source || !target || _typeof(source) !== 'object' || _typeof(target) !== 'object') {\n    return false;\n  }\n  var sourceKeys = Object.keys(source);\n  var targetKeys = Object.keys(target);\n  var keys = new Set([].concat(sourceKeys, targetKeys));\n  return _toConsumableArray(keys).every(function (key) {\n    var sourceValue = source[key];\n    var targetValue = target[key];\n    if (typeof sourceValue === 'function' && typeof targetValue === 'function') {\n      return true;\n    }\n    return sourceValue === targetValue;\n  });\n}\nexport function defaultGetValueFromEvent(valuePropName) {\n  var event = arguments.length <= 1 ? undefined : arguments[1];\n  if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {\n    return event.target[valuePropName];\n  }\n  return event;\n}\n/**\n * Moves an array item from one position in an array to another.\n *\n * Note: This is a pure function so a new array will be returned, instead\n * of altering the array argument.\n *\n * @param array         Array in which to move an item.         (required)\n * @param moveIndex     The index of the item to move.          (required)\n * @param toIndex       The index to move item at moveIndex to. (required)\n */\nexport function move(array, moveIndex, toIndex) {\n  var length = array.length;\n  if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {\n    return array;\n  }\n  var item = array[moveIndex];\n  var diff = moveIndex - toIndex;\n  if (diff > 0) {\n    // move left\n    return [].concat(_toConsumableArray(array.slice(0, toIndex)), [item], _toConsumableArray(array.slice(toIndex, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, length)));\n  }\n  if (diff < 0) {\n    // move right\n    return [].concat(_toConsumableArray(array.slice(0, moveIndex)), _toConsumableArray(array.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array.slice(toIndex + 1, length)));\n  }\n  return array;\n}"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,OAAO,MAAM,mCAAmC;AACvD,OAAOC,GAAG,MAAM,sBAAsB;AACtC,OAAOC,GAAG,MAAM,sBAAsB;AACtC,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,SAAS,MAAM,oBAAoB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAW,CAACC,IAAI,EAAE;EAChC,OAAOH,OAAO,CAACG,IAAI,CAAC;AACtB;AACA,OAAO,SAASC,QAAQ,CAACC,KAAK,EAAEC,QAAQ,EAAE;EACxC,IAAIC,KAAK,GAAGT,GAAG,CAACO,KAAK,EAAEC,QAAQ,CAAC;EAChC,OAAOC,KAAK;AACd;AACA,OAAO,SAASC,QAAQ,CAACH,KAAK,EAAE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